package com.gagakuai.bpm.api.camunda;




import com.gagakuai.bpm.domian.dto.response.ResponseStatusDto;
import com.gagakuai.bpm.domian.dto.scheduleTask.BPMUserVo;
import com.gagakuai.bpm.service.camunda.SyncUserInfoService;
import com.gagakuai.bpm.utils.ObjectUtils;
import com.gagakuai.bpm.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/bpm/syncUser")
@Api(tags = {"更新单个用户信息"})
@ApiModel("")
public class SyncUserInfoController {


    @Resource
    private SyncUserInfoService syncUserInfoService;

    @ApiOperation("更新单个用户信息")
    @PostMapping("/updateUserInfo")
    public ResponseStatusDto<Void> updateUserInfo(@RequestBody BPMUserVo bpmUserVo){
        if(bpmUserVo.getUserId() <= 0){
            return ResponseStatusDto.failure("参数：【userId】 有误");
        }

        if(StringUtils.isEmpty(bpmUserVo.getUsername())){
            return ResponseStatusDto.failure("参数：【userName】 不能为空");
        }

        if(ObjectUtils.isNull(bpmUserVo.getDeptInfo())){
            return ResponseStatusDto.failure("参数：部门信息不能为空");
        }

        if(syncUserInfoService.updateUserInfo(bpmUserVo) > 0){
            return ResponseStatusDto.success();
        }

        return ResponseStatusDto.failure("更新数据失败");
    }


    @ApiOperation("获取去用户信息")
    @GetMapping("/getUserInfo/{userId}")
    public ResponseStatusDto<Void> getUserInfo(@PathVariable("userId")Long userId){


        return ResponseStatusDto.failure("更新数据失败");
    }





}
